<%@page import="java.util.List"%>
<%@page import="com.wanmait.cookbook.vo.Province"%>
<%@page import="com.wanmait.cookbook.vo.Userinfo"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
String path = request.getContextPath();
%>
<!DOCTYPE html>

<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    <title>设置我的基本资料-南瓜美食</title>
    <link rel="icon" href="https://cp1.douguo.com/static/nweb/images/favicon.ico?v=1912" type="image/x-icon">
    <link rel="stylesheet" href="<%=path %>/static/css/main.css">
            <link rel="stylesheet" href="<%=path %>/static/css/setting.css">
        <script src="<%=path %>/static/js/osd.js.下载"></script><script src="./static/f.txt" id="google_shimpl"></script><script src="./static/js/hm.js.下载"></script><script src="./static/js/jquery.js.下载"></script>
    <script data-ad-client="ca-pub-6608973961595981" async="" src="./static/f(1).txt" data-checked-head="true"></script>
    
<link rel="preload" href="./static/f(2).txt" as="script"><script type="text/javascript" src="./static/f(2).txt"></script></head>
<script type="text/javascript" src="<%=request.getContextPath()%>/static/js/jquery-3.5.1.min.js"></script>
<body>

<jsp:include page="/inc/head.jsp"></jsp:include>
<ins class="adsbygoogle adsbygoogle-noablate" data-adsbygoogle-status="done" style="display: none !important;"><ins id="aswift_0_expand" style="display:inline-table;border:none;height:0px;margin:0;padding:0;position:relative;visibility:visible;width:0px;background-color:transparent;"><ins id="aswift_0_anchor" style="display:block;border:none;height:0px;margin:0;padding:0;position:relative;visibility:visible;width:0px;background-color:transparent;"><iframe id="aswift_0" name="aswift_0" style="left:0;position:absolute;top:0;border:0;width:undefinedpx;height:undefinedpx;" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" frameborder="0" src="./static/ads.html" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" data-google-container-id="a!0" data-load-complete="true"></iframe></ins></ins></ins><script>
</script>
<%	

Userinfo userinfo = (Userinfo)session.getAttribute("userinfo");
List<Province> allProvinces = (List<Province>)request.getAttribute("allProvinces");
Integer userinfoCity = userinfo.getCity().getId();
%>
<div id="content" class="clearfix">
<form id="userinfo" method="post"  enctype="multipart/form-data" action ="<%=path %>/UserInfoServlet?action=updateUserinfo&id=<%=userinfo.getId()%>">
    <div id="left">
         <div class="type-tab">
<div class="type-head clearfix">
    <a href="" class="active">基本资料</a>

    
</div>
</div>
 
 <div style="margin-left:50px">       
            <input type="hidden" name="userHead" value="">
            <label for="ema il">
                            </label>
            <label for="nickname">
                <span>昵称</span> <input type="text" id="nickname" name="nickname" value="<%=userinfo.getName() %>">
                <span id="namespan" style="color:red;"></span>
            </label>
             <label for="email">
                            </label>
            <label >
                <span>电话</span> <input type="text" id="telephone" name="telephone" value="<%=userinfo.getTelephone() %>">
                <span id="telephonespan" style="color:red;"></span>
            </label>
 </div>
            <div class="option">
           <%
           	boolean sex = userinfo.getSex();
            	
           %>
                 <span>性别</span>
              <select id = "selectSex" name="selectSex">
              <%
if(sex){
%>
<option id="selectMan" value="男" selected>男</option>
              	<option id="selectWoman"value="女" >女</option>
              	<%
}else{
%>
<option id="selectMan" value="男" >男</option>
              	<option id="selectWoman"value="女" selected>女</option>
              	<%
}              
              
              %>
              </select>
            </div>
            <div class="option birthday">
                <span>生日</span>
                <%
                String brithday = userinfo.getBirthday().toString();
                String brithdays = brithday.substring(0, 10);
           	
                %>	 	  	 	
 	<input type="date" name="birthday" id="date" value="<%=brithdays%>">	
                <b></b>
            </div>
            <div class="option address">
                <span>地址</span>
                <!-- <select name="cur_province" id="province" onchange="getProvince(this.value,0)"><option value="1">北京</option><option value="2">上海</option><option value="3">天津</option><option value="4">重庆</option><option value="5">广东</option><option value="6">福建</option><option value="7">浙江</option><option value="8">江苏</option><option value="9">山东</option><option value="10">辽宁</option><option value="11">江西</option><option value="12">四川</option><option value="13">陕西</option><option value="14">湖北</option><option value="15">河南</option><option value="16">河北</option><option value="17">山西</option><option value="18">内蒙古</option><option value="19">吉林</option><option value="20">黑龙江</option><option value="21">安徽</option><option value="22">湖南</option><option value="23">广西</option><option value="24">海南</option><option value="25">云南</option><option value="26">贵州</option><option value="27">西藏</option><option value="28">甘肃</option><option value="29">宁夏</option><option value="30">青海</option><option value="31">新疆</option><option value="32">香港</option><option value="33">澳门</option><option value="35">台湾</option><option value="3118">海外</option></select> -->
                <select id="province">
                	<%
for(Province province:allProvinces){
%>
<option value="<%=province.getId()%>"><%=province.getName() %></option>
<% 
}                	
                	%>
                </select>
                
                
                <select name="cityId" id="city">

                </select>
            </div>
            <div class="option kouwei">
                <span>口味</span>
                <select name="kouwei" id="kouwei">
                    <option value="">请选择</option>
                    <option value="酸">酸</option>
                    <option value="甜">甜</option>
                    <option value="苦">苦</option>
                    <option value="辣">辣</option>
                    <option value="咸">咸</option>
                    <option value="香辣">香辣</option>
                    <option value="酸甜">酸甜</option>
                    <option value="咸苦">咸苦</option>
                    <option value="酸苦">酸苦</option>
                    <option value="微辣">微辣</option>
                    <option value="变态辣">变态辣</option>
                    <option value="超级咸">超级咸</option>
                    <option value="腻人甜">腻人甜</option>
                    <option value="无敌酸">无敌酸</option>
                    <option value="清淡">清淡</option>
                    <option value="通吃">通吃</option>
                    <option value="重口味">重口味</option>
                </select>
            </div>
            <div class="option jieshao">
                <span>自我介绍</span> <textarea name="jieshao" id = "jieshao" placeholder="你也想成为老八一样的美食家吗？？
介绍下自己，填写你认为自己称得上美食达人的理由。"><%=userinfo.getInfo()%></textarea>
            </div>
            <input type="hidden" name="_token" value="XJm8NIr9iQCC6AGzQDtwakqpnbZFS3MUFh73gVXs">
            <a href="javascript:void(0)" class="save" id="save">保存</a>
        	<span id="savespan" style="color:red;"></span>
    </div>
    <div id="right">
        <div class="user-head" style="margin-top:75px;">
      
     <input id="file" class="filepath" onchange="changepic(this)" type="file" name="pic" style="width:200px;border:0px;"><br>
    	
    	<img src="<%=path %>/static/image/<%=userinfo.getAvatar()%>" id="show" width="200">

        </div>
    </div>
    
</form>
</div>
<jsp:include page="/inc/foot.jsp"></jsp:include>
            <script src="./static/js/ajaxfileupload.js.下载"></script>
    <script src="./static/js/tip.js.下载"></script>
<script src="./static/js/search.js.下载"></script>
<script src="./static/js/main.js.下载"></script>
<!-- <script src='https://s13.cnzz.com/c.php?id=30029854' language='JavaScript' charset='gb2312'></script> -->
<script src="<%=request.getContextPath() %>/static/js/jquery-3.5.1.min.js" type="text/javascript"></script>

<script>

   $(function(){
   provinceCity();


  	$("#selectSex").change(function(){
  	 	var sex = $(this).val();

  	 	$.ajax({
  	url:"<%=path%>/UserInfoServlet",
  	data:{action:"sex",sex:sex},
  	success:function(mes){
  	
  	}
  	});
  	 	});
  	
  	$("#province").change(provinceCity);

  	
 //找到用户所在的省份 	
var userinfoCity = <%=userinfoCity%>;
var provinceId = null;

  	$.ajax({
  	url:"<%=path%>/UserInfoServlet",
  	type:"get",
  	async:false,
  	data:{action:"userinfoCity",userinfoCity:userinfoCity},
  	success:function(mes){
  	$("#province").val(mes);  
  	provinceId =mes;
  	}
  	});
//找到用户所在的城市
  	$.ajax({
  	url:"<%=path%>/UserInfoServlet",
  	
  	data:{action:"provinceId",provinceId:provinceId},
  	success:function(mes){
  	$("#city").html(mes);
  	$("#city").val(<%=userinfo.getCity().getId()%>);
  	}
  	});
 	
  	 $("#kouwei").val("<%=userinfo.getTaste()%>"); 
  
 //提交表单
 	
 	var name = null;
 	$("#nickname").blur(function(){
 	name = $("#nickname").val();
 	$("#savespan").html("");
 	if(name==""){
$("#namespan").html("不能为空");	
$("#nickname").seclct();
return;
}else{
$("#namespan").html("");

}	  
 	});
 	
 	var telephone = null;
 	
 	$("#telephone").blur(function(){
 	$("#savespan").html("");
 	telephone = $("#telephone").val();
 	var format = /^\d{11}$/
 	 	var flag = format.test(telephone);
 	
 	if(!flag){
$("#telephonespan").html("请输入正确的号码");
$("#telephone").seclct();
return;
}else{
$("#telephonespan").html("");	
}	 	
 	});
 	$("#save").click(function(){
 	var formats = /^\d{11}$/
 	
 	name = $("#nickname").val();
 	telephone = $("#telephone").val();
 	var flags = formats.test(telephone);
 	if(name==""||!flags){
 	$("#savespan").html("请完善修改");
 	return;
 	}
 	$("#userinfo").submit();
 	
 	})	  	
   });
     
   function provinceCity(){
 	var province = $("#province").val();
 	
 	$.ajax({
url:"<%=path%>/UserInfoServlet",
type:"get",
data:{action:"province",province:province},	
success:function(mes){
$("#city").html(mes);

}
});
 }
   function changepic() {
       var reads= new FileReader();
       f=document.getElementById('file').files[0];
   	reads.readAsDataURL(f);
       reads.onload=function (e) {
           document.getElementById('show').src=this.result;
       };
   }
</script>

<iframe id="google_osd_static_frame_424902095950" name="google_osd_static_frame" style="display: none; width: 0px; height: 0px;" src="./static/saved_resource.html"></iframe></body><iframe id="google_esf" name="google_esf" src="./static/zrt_lookup.html" data-ad-client="ca-pub-6608973961595981" style="display: none;"></iframe></html>